我不明白这是怎么回事。我应该如何输入gsub以获取字符串“Yaho\'o”?>>"Yaho'o".gsub("Y","\\Y")=>"\\Yaho'o">>"Yaho'o".gsub("'","\\'")=>"Yahooo" 最佳答案 \'表示$'是匹配后的所有内容。再次转义\就可以了"Yaho'o".gsub("'","\\\\'") 关于Rubygsub不会转义单引号,我们在StackOverflow上找到一个类似的问题: https://stackove
选择有意义。但是有人可以向我解释.detect吗?我不明白这些数据。>>[1,2,3,4,5,6,7].detect{|x|x.between?(3,4)}=>3>>[1,2,3,4,5,6,7].detect{|x|x.between?(3,6)}=>3>>[1,2,3,4,5,6,7].detect{|x|x.between?(3,7)}=>3>>[1,2,3,4,5,6,7].detect{|x|x.between?(2,7)}=>2>>[1,2,3,4,5,6,7].detect{|x|x.between?(1,7)}=>1>>[1,2,3,4,5,6,7].detect{|x